"""Added Country model

Revision ID: bc0959b766b9
Revises: d323ff8d244e
Create Date: 2024-05-04 14:59:09.369085

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "bc0959b766b9"
down_revision = "d323ff8d244e"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "country",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=255), nullable=False),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_country")),
    )
    op.add_column("category", sa.Column("country_id", sa.Integer(), nullable=True))
    op.create_foreign_key(
        op.f("fk_category_country_id_country"),
        "category",
        "country",
        ["country_id"],
        ["id"],
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("fk_category_country_id_country"), "category", type_="foreignkey"
    )
    op.drop_column("category", "country_id")
    op.drop_table("country")
    # ### end Alembic commands ###
